package com.example.ovulationperiodtracker.Allactivity;

import android.database.Cursor;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.widget.ListView;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;

import com.example.ovulationperiodtracker.R;
import com.example.ovulationperiodtracker.adapter.MedicineAdapter;
import com.example.ovulationperiodtracker.databinding.ActivityMedicineBinding;
import com.example.ovulationperiodtracker.model.Settings;
import com.example.ovulationperiodtracker.model.User;
import com.example.ovulationperiodtracker.periodadepter.PillsFragment5Adapter;
import com.example.ovulationperiodtracker.utils.Constants;
import com.example.ovulationperiodtracker.utils.JCGSQLiteHelper;
import com.example.ovulationperiodtracker.utils.MyLog;
import com.example.ovulationperiodtracker.view.NavigationView;
import com.example.ovulationperiodtracker.view.NoteUtils;
import com.necer.base.BaseActivity;
import com.tencent.mmkv.MMKV;

import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.Date;
import java.util.List;

/**
 * 药品
 */
public class MedicineActivity extends BaseActivity<ActivityMedicineBinding> {
    private NoteUtils.DayNote dayNote;

    @Override
    protected ActivityMedicineBinding createBinding(LayoutInflater inflater) {
        return ActivityMedicineBinding.inflate(inflater);
    }


    @Override
    protected void onCreated(Bundle savedInstanceState) {

        LocalDate localDate = (LocalDate) getIntent().getSerializableExtra("datekey");
        dayNote = NoteUtils.getDayNote(localDate);
        MedicineAdapter medicineAdapter = new MedicineAdapter(context,binding.recyclerView);
        medicineAdapter.setCheckedMedicines(dayNote.medicines);
        binding.recyclerView.setLayoutManager(new LinearLayoutManager(context));
        binding.recyclerView.setAdapter(medicineAdapter);

        binding.navigation.setOnClickRightListener(new NavigationView.OnClickRightListener() {
            @Override
            public void onClickRight() {
                String medicines = medicineAdapter.getCheckedMedicines();
                dayNote.medicines = medicines;
                NoteUtils.saveDayNote(dayNote);
                finish();
            }
        });
    }
}
